package main

import (
	"fmt"
	"myserver/app/jwt"
	"myserver/app/model"
	"myserver/app/redis"
	"myserver/cmd"
	"myserver/pkg/config"
	"myserver/pkg/console"
	modelrsa "myserver/pkg/rsa"
	"os"

	"github.com/spf13/cobra"
)

func init() {
	config.Viper()
	e := redis.Setup()
	if e != nil {
		fmt.Println("链接出错")
	}
	jwt.Setup()
	model.Setup()
	model.CreateTable()
	modelrsa.SetUp()

}
func main() {
	var rootCmd = &cobra.Command{
		Use:   "",
		Short: "",
		Long:  "will run serve command",

		PersistentPreRun: func(cmd *cobra.Command, args []string) {

		},
	}

	rootCmd.AddCommand(cmd.CmdServe)

	// 配置默认运行 Web 服务
	cmd.RegisterDefaultCmd(rootCmd, cmd.CmdServe)

	// 注册全局参数，--env
	cmd.RegisterGlobalFlags(rootCmd)

	// 执行主命令
	if err := rootCmd.Execute(); err != nil {
		console.Exit(fmt.Sprintf("Failed to run app with %v: %s", os.Args, err.Error()))
	}
}
